import { useRef, useState } from "react";
import Child from "./Child";

export default function Parent() {
  const [list, setlist] = useState(["html", "css", "js"]);

  const inputRef = useRef(null);

  const handle = () => {
    setlist([...list, inputRef.current.value]);
  };

  return (
    <div>
      <div className="hd">
        <input type="text" ref={inputRef} />
        <button onClick={handle}>确认</button>
      </div>
      <Child list={list} />
    </div>
  );
}
